/**********************************************************/
/* Goblin Defense - A tower defense game for Wii Homebrew */
/* Copyright (C) 2009 Ricardo Bueno Cordeiro              */
/* Licensed under de GNU General Public License v2.0      */
/*   See license_gplv2.txt for detalis                    */
/**********************************************************/

#include <gccore.h>
#include <math.h>

#include "weapon.h"

void UpgradableWeapon::draw_selected_area(u8 cr, u8 cg, u8 cb, u8 ca) {
	f32 x = this->get_x();
	f32 y = this->get_y();
	f32 r = this->get_radius();

	u32 sides = (u32)r;
	f32 angle_part = 2.0 * M_PI / ((f32)sides);
	
	GX_Begin(GX_TRIANGLEFAN, GX_VTXFMT0, sides + 2);

	GX_Position3f32(x, y, 0.0);
	GX_Color4u8(cr, cg, cb, ca);

	for (u32 i = 0; i <= sides; i++) {
		f32 rcos = cos(angle_part * ((f32)i));
		f32 rsin = sin(angle_part * ((f32)i));

		GX_Position3f32(x + rcos * r, y + rsin * r, 0.0);
		GX_Color4u8(cr, cg, cb, ca);
	}

	GX_End();
}
